import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RestockingPlanVO, RestockingPlanForm, RestockingPlanQuery } from '@/api/plan/restockingPlan/types';

/**
 * 查询补货计划列表
 * @param query
 * @returns {*}
 */

export const listRestockingPlan = (query?: RestockingPlanQuery): AxiosPromise<RestockingPlanVO[]> => {
  return request({
    url: '/oa/restockingPlan/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询补货计划详细
 * @param id
 */
export const getRestockingPlan = (id: string | number): AxiosPromise<RestockingPlanVO> => {
  return request({
    url: '/oa/restockingPlan/' + id,
    method: 'get'
  });
};

/**
 * 新增补货计划
 * @param data
 */
export const addRestockingPlan = (data: RestockingPlanForm) => {
  return request({
    url: '/oa/restockingPlan',
    method: 'post',
    data: data
  });
};

/**
 * 修改补货计划
 * @param data
 */
export const updateRestockingPlan = (data: RestockingPlanForm) => {
  return request({
    url: '/oa/restockingPlan',
    method: 'put',
    data: data
  });
};

/**
 * 删除补货计划
 * @param id
 */
export const delRestockingPlan = (id: string | number | Array<string | number>) => {
  return request({
    url: '/oa/restockingPlan/' + id,
    method: 'delete'
  });
};

export const stat = (ids: Array<string | number>) => {
  return request({
    url: '/oa/restockingPlan/stat',
    method: 'post',
    data: ids
  });
};

export const statAll = () => {
  return request({
    url: '/oa/restockingPlan/statAll',
    method: 'post',
    data: null
  });
};
